package com.bst.base.service.impl;

import java.util.Date;
import java.util.List;

import com.bst.common.utils.self.LoginAPIUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bst.base.mapper.BaseReportCacheLockMapper;
import com.bst.base.domain.BaseReportCacheLock;
import com.bst.base.service.IBaseReportCacheLockService;
import com.bst.common.core.text.Convert;

/**
 * 缓存锁定Service业务层处理
 * 
 * @author laoliu
 * @date 2024-12-31
 */
@Service
public class BaseReportCacheLockServiceImpl implements IBaseReportCacheLockService 
{
    @Autowired
    private BaseReportCacheLockMapper baseReportCacheLockMapper;

    /**
     * 查询缓存锁定
     * 
     * @param idReportCacheLock 缓存锁定主键
     * @return 缓存锁定
     */
    @Override
    public BaseReportCacheLock selectBaseReportCacheLockByIdReportCacheLock(Long idReportCacheLock)
    {
        return baseReportCacheLockMapper.selectBaseReportCacheLockByIdReportCacheLock(idReportCacheLock);
    }

    /**
     * 查询缓存锁定列表
     * 
     * @param baseReportCacheLock 缓存锁定
     * @return 缓存锁定
     */
    @Override
    public List<BaseReportCacheLock> selectBaseReportCacheLockList(BaseReportCacheLock baseReportCacheLock)
    {
        return baseReportCacheLockMapper.selectBaseReportCacheLockList(baseReportCacheLock);
    }

    /**
     * 新增缓存锁定
     * 
     * @param baseReportCacheLock 缓存锁定
     * @return 结果
     */
    @Override
    public int insertBaseReportCacheLock(BaseReportCacheLock lock)
    {
        lock.setDtSysCre(new Date());
        lock.setNaEmpCre(LoginAPIUtils.getLoginUsename());
        lock.setFgLock(1);
        return baseReportCacheLockMapper.insertBaseReportCacheLock(lock);
    }

    /**
     * 修改缓存锁定
     * 
     * @param baseReportCacheLock 缓存锁定
     * @return 结果
     */
    @Override
    public int updateBaseReportCacheLock(BaseReportCacheLock baseReportCacheLock)
    {
        return baseReportCacheLockMapper.updateBaseReportCacheLock(baseReportCacheLock);
    }

    /**
     * 批量删除缓存锁定
     * 
     * @param idReportCacheLocks 需要删除的缓存锁定主键
     * @return 结果
     */
    @Override
    public int deleteBaseReportCacheLockByIdReportCacheLocks(String idReportCacheLocks)
    {
        return baseReportCacheLockMapper.deleteBaseReportCacheLockByIdReportCacheLocks(Convert.toStrArray(idReportCacheLocks));
    }

    /**
     * 删除缓存锁定信息
     * 
     * @param idReportCacheLock 缓存锁定主键
     * @return 结果
     */
    @Override
    public int deleteBaseReportCacheLockByIdReportCacheLock(Long idReportCacheLock)
    {
        return baseReportCacheLockMapper.deleteBaseReportCacheLockByIdReportCacheLock(idReportCacheLock);
    }

    @Override
    public int isBaseReportCacheLock(String cDate, Long idReportChche) {
        BaseReportCacheLock lock = new BaseReportCacheLock();
        lock.setcDate(cDate);
        lock.setIdReportCache(idReportChche);
        List<BaseReportCacheLock> locks = this.selectBaseReportCacheLockList(lock);
        return locks.size()>0?1:0;
    }

    @Override
    public List<BaseReportCacheLock> selectLockDataByPids(String[] ids, String cDate) {
        return baseReportCacheLockMapper.selectLockDataByPids(ids,cDate);
    }
}
